﻿/*
 * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2023-2023. All rights reserved.
 */

#ifndef DIAGLOGCOMSETTING_H
#define DIAGLOGCOMSETTING_H

#include <QWidget>
#include <QSerialPort>
#include "ui_MenuSettings.h"
#include "BurnToolCommon/StdAfx.h"
#include "BurnToolCommon/Global.h"

class DiaglogComSetting : public QWidget {
    Q_OBJECT
public:
    explicit DiaglogComSetting(QWidget *pParent = nullptr); // 标准构造函数
    ~DiaglogComSetting() final;
    void SetCurrentValue() const;
    int GetYModemPackageSize() const;
    void SetYModemPackageSize(int packageSize);
    void GetComConfig(int &baudRate, int &databit, int &stopbit,
        QSerialPort::Parity &tparity, int &flowControl) const;
    void SetComConfig(const int &baudRate, const int &databit, const int &stopbit,
                      const QSerialPort::Parity &tparity, const int &flowControl);
    void SetForceRead(bool forceRead);
    bool GetForceRead() const;
    void SetForceReadTimr(UINT time);
    UINT GetForceReadTime() const;
    void SetMultipleBurnParam(unsigned int totalNumber, unsigned int numPerLines,
        bool indenpendent, bool reopenComFlag);
    void SetIsResetAfterSuccess(bool resetAfterSuccess);
    void SetIsSwitchAfterLoader(bool switchAfterLoader);
    void GetMultipleBurnParam(unsigned int &totalNumber, unsigned int &numPerLines,
                              bool &indenpendent, bool &reopenComFlag) const;
    void GetIsResetAfterSuccess(bool &resetAfterSuccess) const;
    void Set3XSettingShow(ChipType chipType);
    void GetIsSwitchAfterLoader(bool &isSwitchAfterLoaderBurn) const;
    void mousePressEvent(QMouseEvent *event) final;
    void Set4GCat1TotalAndLineNum(ChipType chipType);
    void ComSettingEnable(bool isEnable) const;
signals:
    void SignalSettingSuccess();
private:
    Ui::MenuSettings *ui;
    int baud;     // 波特率
    QSerialPort::Parity parity;  // 校验
    int databits; // 数据位
    int stopbits; // 停止位
    int flowctrl;  // 流控
    int eachPackageSize; // 分包大小
    bool isForceRead;
    unsigned int forceReadTime;
    bool independent;
    bool isReopenComFlah;
    bool isResetAfterSuccess;
    bool isSwitchAfterLoader;
    unsigned int totalNum;
    unsigned int numPerLine;
private:
    void InitUi();

private slots:
    void SlotOkButtonClick();
    void SlotCancelButtonClick();
};
#endif
